package com.example.thymeleaf.dao;

import com.example.thymeleaf.pojo.Blog;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BlogDao {
    /**
     * 查询所有
     * */
    @Select("select * from t_blog")
    List<Blog> selectBlog();

    /**
     * 根据id查询
     * */
    @Select("select * from t_blog where id = #{id}")
    Blog selectBlogByID(Integer id);

    /**
     * 添加
     * */
    @Insert(" insert into t_blog (title, content, create_date) values (#{title},#{content},#{createDate})")
    int addBlog(Blog blog);

    /**
     * 修改
     * */
    @Update("update t_blog set title=#{title}, content=#{content} where id=#{id}")
    int updateBlog(Blog blog);

    /**
     * 删除
     * */
    @Delete("delete from t_blog where id=#{id}")
    int deleteBlog(Integer id);
}
